<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/icon/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/supplies/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/loading.css">
    <link rel="stylesheet" href="/js/supplies/ztree/css/metroStyle/metroStyle.css"/>
    <link rel="stylesheet" href="/js/supplies/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="/css/supplies/common.css"/>
    <link rel="stylesheet" href="/css/supplies/shop/shop.css"/>
    <style>
        body {
            padding: 0px 20px;
            -webkit-height: calc(100% - 80px);
            -moz-height: calc(100% - 80px);
            height: calc(100% - 80px);
            overflow: hidden;
        }

        .nav > li > a {
            position: relative;
            display: block;
        }

        .model-li {
            float: left;
            padding: 10px 0px 10px 0px;
            width: 30%;
            margin-right: 20px;
            margin-bottom: 10px;
            font-size: 14px;
            min-width: 100px;
            text-align: center;
            font-weight: 100;
            color: #666;
            background-color: #FFECE0;
            border: 1px solid #FFECE0;
        }

        .area-model-li {
            float: left;
            margin-right: 20px;
            margin-top: 10px;
            font-size: 14px;
            min-width: 100px;

        }

        .area-model-li span {
            margin: 10px 10px;
        }

        .model-li span {
            margin: 10px 10px;

        }

        #mainCategories .model-li span {
            width: 100%;
            margin: 0px;
        }

        .post_code {
            width: 260px
        }

        /*.layui-layer-btn0:hover {*/
        /*background: #2e8ded;*/
        /*!important;*/
        /*}*/

        .shop-logo {
            margin-top: -70px;
        }
        #myTabContent {
            background-color: white;
            padding: 20px 20px;
            margin-top: 20px;
            -webkit-height: calc(100% - 220px);
            -moz-height: calc(100% - 220px);
            height: calc(100% - 220px);
            overflow: auto
        }
    </style>
</head>
<body>

<ul id="myTab" class="nav nav-tabs">
    <li class="active">
        <a href="#basic" data-toggle="tab">
            <span class="font_size_14">基本信息</span> </br><span class="font_size_14 en_title">basic information</span>
            <div class="title-bottom-border"></div>
        </a>
    </li>
    <li>
        <a href="#area" data-toggle="tab">
            <span class="font_size_14">配送地区</span></br><span class="font_size_14 en_title">distribution area</span>
            <div class="title-bottom-border"></div>
        </a>
    </li>
</ul>

<div id="myTabContent" class="tab-content" >

    <div class="tab-pane fade in active" id="basic" v-loading="loading">
        <div class="logo form-inline save_commodity_td">
            <span class="form-group basic_name shop-logo ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_header.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">店铺logo</br>
                    <span class="font_size_14 color-6">
                        store's logo</span>
                </span>
            </span>
            <div class="logo_file  form-group" style="position: relative">
                <div class="images">
                    <img :src="info.image" onerror="src='/image/supplies/logo.png'"/>
                </div>
                <a href="javascript:;" class="file_edit form-group">修改</br>
                    <input type="file" @change="uploadImg" id="img" accept="image/jpeg,image/png,image/jpg"
                           style="margin-top: 3px;" multiple="multiple">
                </a>
                <div class="tishi font_size_14 form-group">建议尺寸:150*150,支持的图片格式;jpg、png、gif、jpeg</div>
            </div>
        </div>
        <div class="form-inline save_commodity_td shop_name_td">
            <span class="basic_name form-group ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_name.png');background-size: 100%;background-repeat: no-repeat"></span>
                    <span class="form-group font_size_14 margin-left-10">店铺名称</br><span class="font_size_14 color-6">store name</span></span>
                </span>
            <div class="form-group simple">
                <div class="placeholder ">请输入店铺名称<br/><span
                        class="font_size_14">please enter store name</span>
                </div>
                <input type="text" v-model="info.name" isvalid="yes" checkexpession="NotNull" errormsg="请输入店铺名称<br/>please enter store name"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="form-inline save_commodity_td shop_name_td">
            <span class="basic_name form-group ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_store_name.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">联系人</br><span
                        class="font_size_14 color-6">contact</span></span>
            </span>
            </span>
            <div class="form-group simple">
                <div class="placeholder" style="width: 100%">请输入联系人</br><span>please enter contact</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.manager" errormsg="请输入联系人<br/>please enter contact"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="form-inline save_commodity_td shop_name_td">
            <span class="basic_name form-group ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_tel.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">联系电话</br><span class="font_size_14 color-6">contact phone number</span></span>
            </span>
            <div class="form-group simple">

                <div class="placeholder " style="width:100%;">

                    请输入联系电话</br><span>please enter contact phone number</span></div>
                <input type="text" style="z-index: 8888;" v-model="info.tel" errormsg="请输入联系电话<br/>please enter contact phone number"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="form-inline save_commodity_td shop_name_td">
            <span class="basic_name form-group ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_company_reg.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">
                    公司注册号码</br>
                    <span class="font_size_14 color-6">company reg</span></span>
            </span>
            <div class="form-group simple">

                <div class="placeholder ">请输入公司注册号码</br><span

                        style="font-size: 14px">please enter company's registration number</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.company_code" errormsg="请输入公司注册号码<br/>please enter company's registration number"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="save_commodity_td form-inline">
            <span class="form-group basic_name ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_store_intro.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">店铺简介</br><span class="font_size_14 color-6">store description</span></span>
            </span>
            <div class="form-group simple">
                <div class="placeholder ">请输入店铺简介</br><span
                        style="font-size: 14px">please enter a brief description of your store</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.shop_introduction" errormsg="请输入店铺简介<br/>please enter a brief description of your store"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="save_commodity_td form-inline">
            <span class="form-group basic_name ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_main_categories.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">主营类目</br><span class="font_size_14 color-6">main category</span></span>
            </span>
            <div class="form-group simple">
                <div class="placeholder " data-toggle="modal" data-target="#mainCategories">请选择主营类目</br><span
                        style="font-size: 14px">please select the main category</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.business_name" errormsg="请选择主营类目<br/>please select the main category"
                       data-toggle="modal" data-target="#mainCategories"
                       class="bottom_input input_placeholder"/>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.business"
                       style="display: none"/>
            </div>
        </div>
        <div class="save_commodity_td form-inline">
            <span class="form-group basic_name ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_store_postcode.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">店铺邮编</br><span class="font_size_14 color-6">store's postcode</span></span>
            </span>
            <div class="form-group simple" style="width: calc(100% - 400px);">
                <div class="placeholder ">请填写邮编</br><span>please enter postcode</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.post_code"  errormsg="请填写邮编<br/>please enter postcode"
                       class="bottom_input input_placeholder"/>
            </div>
            <div class=" address-btn btn-full font_size_14 b" style="width:128px;height: 40px;line-height: 18px"
                 @click="getAddress()">获取地址</br>(obtain address)
            </div>

        </div>
        <div class="save_commodity_td form-inline">
            <span class="form-group basic_name ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_address.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">店铺地址</br><span
                        class="font_size_14 color-6">store's address</span></span>
            </span>
            <div class="form-group simple">
                <div class="placeholder ">请选择地址</br><span>please select address</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" v-model="info.address"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="save_commodity_td form-inline">
            <span class="form-group basic_name ">
                <span class="titl_img form-group"
                      style="margin-top: -10px;background-image: url('/image/supplies/shop/shop_address.png');background-size: 100%;background-repeat: no-repeat"></span>
                <span class="form-group font_size_14 margin-left-10">最低消费</br><span
                        class="font_size_14 color-6">minimum consumption</span></span>
            </span>
            <div class="form-group simple">
                <div class="placeholder ">请填写本店最低消费</br><span>please fill in our minimum consumption</span></div>
                <input type="text" isvalid="yes" checkexpession="NotNull" id="minimumNum" v-model="info.minimum"
                       class="bottom_input input_placeholder"/>
            </div>
        </div>
        <div class="save_commodity_td" style="border: none;margin-top: 30px;">
            <div class="select_a btn-2 font_size_14" @click="submitInfo()"
                 style="margin: 0 auto;line-height: 30px;width: 100px;height: 32px">修改(amend)
            </div>
        </div>
    </div>
    <div class="tab-pane fade" id="area">
        <div class="form-inline save_commodity_td">
            <span class="form-group basic_name font_size_14">配送日程</br><span class="font_size_13 color-6">delivery schedule</span></span>
            <div id="send_time_week" class="btn-full form-group font_size_14 b distribution_btn"
                 @click="setSchedule($event,1)">星期(week)
            </div>
            <div id="send_time_month" class="btn-null form-group font_size_14 b distribution_btn"
                 @click="setSchedule($event,2)">月(month)
            </div>
        </div>

        <div class="table-box">
            <table class="table" id="weekArea" style="display: none">
                <tbody style="display: table;width: 100%">
                <tr>
                    <th class="th-style text-c color-6" style="width: 15%;">星期</th>
                    <th class="th-style text-c color-6" style="width: 15%;">日历</th>
                    <th class="th-style text-c color-6" style="width: 70%;">配送区域</th>
                </tr>
                <tr class="font_size_16" v-for="(vo,index) in weekArea">
                    <td>{{vo.week}}</td>
                    <td> {{vo.week_day}}</td>
                    <td class="font_size_14 text-l">
                        <div v-if="null == vo.areaInfo " style="float: left ;text-align: left">暂无配送区域<br> <span
                                class="font_size_14 color-6">not distributing to this area at present</span></div>
                        <div v-if="null != vo.areaInfo " class="areaInfo">{{vo.areaInfo}}</div>
                        <div style="float: right">
                            <div style="float: right;margin-right: -8px" class="btn-null font_size_14 b"
                                 data-toggle="modal" data-target="#deleteAddressModal"
                                 @click="addDeleteAreaID(index+1)">
                                删除(delete)
                            </div>
                            <div style="float: left" class="btn-full font_size_14 b" data-toggle="modal"
                                 data-target="#addressModal" @click="editArea(index+1)">编辑(edit)
                            </div>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <table id="monthArea" class="table" style="display: none">
                <tbody style="display: table;width: 100%">
                <tr>
                    <th class="th-style text-c color-6" style="width: 20%;">日期</th>
                    <th class="th-style text-c color-6" style="width: 80%;">配送区域</th>
                </tr>
                <tr class="font_size_16" v-for="(vo,index) in monthArea">
                    <td>{{vo.month_day}}</td>
                    <td class="font_size_14 text-l">
                        <div v-if="null == vo.areaInfo " style="float: left ;text-align: left">暂无配送区域<br> <span
                                class="font_size_14 color-6">not distributing to this area at present</span></div>
                        <div v-if="null != vo.areaInfo " class="areaInfo">{{vo.areaInfo}}</div>
                        <div style="float: right">
                            <div style="float: right;margin-right: -8px" class="btn-null font_size_14 b"
                                 data-toggle="modal" data-target="#deleteAddressModal"
                                 @click="addDeleteAreaID(index)"> 删除(delete)
                            </div>
                            <div style="float: left" class="btn-full font_size_14 b" data-toggle="modal"
                                 data-target="#addressModal" @click="editArea(index+1)">编辑(edit)
                            </div>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <!--<div class="table-box">-->


        <!--</div>-->
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 1300px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">选择可配送范围</br></h4>
                </div>
                <div class="modal-body form-inline">
                    <div class="leftTree form-group">
                        <div class="leftTitle">可选国家.城市/郡县.村镇</br>optional country.City/County.Village</div>
                        <div class="leftContent">
                            <ul id="cityZtree" class="ztree">
                            </ul>
                        </div>
                    </div>
                    <div class="yesBtn form-group">
                        <button onclick="ckeckedTreeNodes();">确定</button>
                    </div>
                    <div class="rightList form-group">
                        <div class="rightTitle">已选国家.城市/郡县.村镇</br>selected country.City/County.Villages</div>
                        <div class="rightContent">
                            <ul>
                                <li v-for="item in rightContentList">{{item.name}}</li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" @click="submitInfo()">提交更改</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <!--获取主营项目-->
    <div class="modal fade" id="mainCategories" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content" style="margin-top:0!important;width:100%;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h2 class="modal-title font_size_14">
                        请选择主营类目范围 <br>
                        please select the main category
                    </h2>
                </div>
                <div class="modal-body">
                    <div class="zTreeDemoBackground left" id="div_tree" style="">
                        <ul id="treeDemo" class="ztree"></ul>
                    </div>
                </div>
                <div style="width: 100% ;  padding-bottom: 20px; ">
                    <div class="select_a btn-2 " data-dismiss="modal" @click="getCheckboxSelect()">确定(determine)</div>
                </div>
                <div style="clear: both"></div>
            </div>

        </div>

    </div>


    <!--店铺获取地址框-->
    <div class="modal fade" id="suppliesAddressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h2 class="modal-title font_size_14">
                        请选择地址 <br> please select address
                    </h2>
                </div>
                <div class="modal-body">
                    <div class="modal-select">
                        <ul>
                            <li class="model-li b" v-for="(vo,index) in list" @click="selectAddr(index)"
                                data-dismiss="modal" aria-hidden="true">
                                <span >{{vo.place_name}},{{vo.admin_name3}},{{vo.admin_name2}},{{vo.admin_name1}}（{{vo.postal_code}}）</span>
                            </li>
                        </ul>
                        <div style="clear: both"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--确定删除配送区域按钮-->
    <div class="modal fade" id="deleteAddressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="logout_modal">
            <div class="model_info">
                <div class="model_info_title ">
                    <span>提示</span>
                </div>
                <div class="model_info_cont font_size_14">
                    确定要删除该数据吗 ?<br>
                    are you sure you want to delete this data ?
                </div>
            </div>
            <div class="font_size_14" style="float: left;width: 100%">
                <div class="btn_save btn_save " data-dismiss="modal" @click="deleteArea()" style="float: left">
                    确认(determine)
                </div>
                <div class="btn_cancel btn-2" data-dismiss="modal" style="float: right">
                    取消(cancel)
                </div>
            </div>
            <div style="clear: both"></div>
        </div>

    </div>


    <!--配送区域-->
    <div class="modal fade" id="addressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h2 class="modal-title font_size_14">
                        请选择配送区域 <br>
                        please select distribution area
                    </h2>
                </div>
                <div class="modal-body">
                    <div class="modal-select">
                        <div v-for="vo in address">
                            <div v-for="(v,index) in vo.area">
                                <div class="area-bg">
                                    <span class="font_size_14 area-text">{{ vo.area[index] }} </span>
                                    <div class="b area-delete" data-target="#deleteAddressAreaModal" data-toggle="modal"
                                         @click="delAddress(vo.area[index])"><span class="fa fa-remove"></span></div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <div class="model_info_cont">
                        <input class="post_code " placeholder="请输入邮编(please enter postcode)" type="text"
                               v-model="post_code">
                        <div class="btn_search btn-2 " @click="search_address()">搜索(search)</div>

                        <div style="clear: both;"></div>
                        <div style="padding-top: 10px">
                            <ul class="search-body">
                                <li class="model-li b" v-for="(vo,index) in area_list" @click="set_address(index)">
                                    <span >{{vo.place_name}},{{vo.admin_name3}},{{vo.admin_name2}},{{vo.admin_name1}}({{vo.postal_code}})</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
<script rel="script" src="/js/supplies/jquery.min.js"></script>
<script rel="script" src="/js/supplies/bootstrap.min.js"></script>
<script rel="script" src="/js/supplies/bootstrap-table/bootstrap-table.min.js"></script>
<script rel="script" src="/js/supplies/ztree/jquery.ztree.all.min.js"></script>
<script rel="script" src="/js/supplies/common.js"></script>
<script rel="script" src="/js/vue.js"></script>
<script rel="script" src="/js/vue-resource.js"></script>
<script rel="script" src="/js/loading.js"></script>
<script rel="script" src="/js/supplies/validator/validator.js"></script>
<script rel="script" src="/js/supplies/common_input.js"></script>
<script rel="script" src="/js/layer.js"></script>
<script rel="script" src="/js/supplies/axios.js"></script>
<script rel="script" src="/js/supplies/shop/shop.js"></script>
<script rel="script">
    var weekDays = getCurrentWeekDays();  //获取本月天数
    var week = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']; //周一 至 周末
    var count = getCurrentMouthDays(); //获取本月天数

    var shop = new Vue({
        el: "#myTabContent",
        data: {
            weekArea: [],//这是配送区域显示数据，需初始化时组装
            monthArea: [],//这是配送区域显示数据，需初始化时组装
            deleteAreaId: '', //要删除的配送地区 ID
            rightContentList: [],
            supplier_id: 0,
            send_time_type: '2',
            info: {
                image: '',
                image_show: '',
                name: '',
                manager: '',
                manager_tel: '',
                tel: '',
                shop_introduction: '',
                business: [],
                business_name: [],
                post_code: '',
                address: '',
                company_code:'',
                minimum:''
            },
            send_time: [],
            list: [],
            country: [],
            city: [],
            district: [],
            address: [],
            day: 0,
            post_code: '',
            area_list: [],
            month_day: '',
            goodsName: [],
            loading: true

        },
        methods: {
            init: function () {
                this.loading=true;
                //请求商户信息
                $.ajax({
                    url: "{:url('supplies/Indexhome/supplierInfo')}",
                    type: 'post',
                    data: {
                        supplier_id: shop.supplier_id
                    },
                    success: function (ret) {
                        shop.info = ret.supplier;
                        shop.info.minimum = ret.supplier.minimum;
                        shop.info.image_show = ret.supplier.image;
                        shop.info.image = oss_url + ret.supplier.image;
                        shop.send_day = ret.send_day;
                        //console.log(shop.info);
                    }
                });
                //请求配送信息
                shop.scheduleInit();
                tipsHidden();
                this.loading=false;
            },
            setCheckboxSelect: function (event) {

                var status;
                $(event.currentTarget).find("input").each(function () {
                    status = $(this).prop("checked");
                    if (status) {
                        $(event.currentTarget).css("border-color", "#FF6A0E");
                    } else {
                        $(event.currentTarget).css("border-color", "#FFECE0 ");
                    }
                });

            },
            getCheckboxSelect: function () {
                var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                var nodes = zTree.getCheckedNodes();
                var name = '';
                shop.info.business = '';
                for (var i = 0; i < nodes.length; i++) {
                    shop.goodsName.push(nodes[i].name);
                    shop.info.business += (nodes[i].id) + ',';
                    name += (nodes[i].name ) + ',';
                }
                shop.info.business = shop.info.business.substr(0, shop.info.business.length - 1);
                shop.info.business_name = name.substr(0, name.length - 1);
                isShowInputTips();
            },
            getAddress: function () {

                if (null == shop.info.post_code || "" == shop.info.post_code || shop.info.post_code.length == 0) {
                    layer.msg("请输入邮编地址",{
                        skin:'winning-class',//自定义样式winning-class
                        time:3000
                    });
                    return;
                }
                $('#suppliesAddressModal').modal(true);
                //请求地址列表
                $.ajax({
                    url: "{:url('apishop/index/getAreaListByCode')}",
                    type: 'post',
                    data: {
                        code: shop.info.post_code
                    },
                    success: function (ret) {
                        //console.log(ret)
                        shop.list = ret.list;
                    }
                });
                //打开模态框
                openAddressModel();
            },
            //选择地址
            selectAddr: function (index) {
                shop.info.post_code = shop.list[index].postal_code;
                shop.info.address = shop.list[index].place_name+','+shop.list[index].admin_name3+','+shop.list[index].admin_name2+','+shop.list[index].admin_name1;
                closeAddressModel();
            },
            submitInfo: function () {
            //console.log($('#basic').Validform()) ;
                if ($('#basic').Validform()) {
                    //console.log(shop.info);
                    $.ajax({
                        url: "{:url('supplies/Indexhome/editInfo')}",
                        type: 'post',
                        data: shop.info,
                        success: function (ret) {
                            layer.msg(ret.msg,{
                                skin:'winning-class',//自定义样式winning-class
                                time:1000
                            });
                            setTimeout(function () {
                                window.location.reload();
                            }, 1000);
                        }
                    });
                }
            },
            // 上传图片
            uploadImg: function (e) {
                this.loading = true;
                var data = new FormData(), _this = this, html = '', url = '/apishop/Product/uploadImg', name, ext;
                $.each(e.target.files, function (i, v) {
                    data.append(e.target.id + '[]', v);
                });
                data.append('dir', 'product');
                data.append('name', e.target.id);
                axios.post(url, data, {
                    emulateJSON: true
                }).then(function (res) {
                    if (res.data.status == 200) {
                        _this.info.image = oss_url + res.data.img[0];
                        _this.info.image_show = res.data.img[0];
                        // alert(JSON.stringify(res.data.img[0]));
                    }else if (res.data.status == 209) {
                        layer.msg('请上传正方形的图片</br>please upload a square picture',{
                            skin:'winning-class',//自定义样式winning-class
                            time:3000
                        })
                    }else {
                        layer.msg('上传失败</br>upload failure',{
                            skin:'winning-class',//自定义样式winning-class
                            time:3000
                        })
                    }
                    _this.loading = false;
                }, function (res) {

                });
            },
            setSchedule: function (event, value) {
                if (shop.send_time_type != value) {
                    layer.confirm('修改配送方式，会清除当前配送信息!确认修改配送方式？<br> ' +
                        'Change the distribution mode and remove the current distribution information!Do you confirm the way to amend the distribution ?', {
                        btn: ['<span class="layer_btn_save">确定(determine)</span>', '取消(cancel)'],
                        move:false,
                        offset: '30px'
                    }, function () {
                        //更新商户配送方式
                        shop.send_time_type = value;
                        updateSendTimeType();
                    });
                }
            },
            scheduleInit: function () {
                $.ajax({
                    url: "{:url('supplies/Indexhome/getSendTimeBySupplierId')}",
                    type: 'post',
                    data: {
                        supplier_id: shop.supplier_id
                    },
                    success: function (ret) {
                        if (200 == ret.status) {
                            shop.send_time = ret.data.send_time;
                            shop.send_time_type = ret.data.send_time_type;

                            if ('2' == shop.send_time_type) {
                                $("#send_time_month").removeClass("btn-null");
                                $("#send_time_month").addClass("btn-full");
                                $("#send_time_week").removeClass("btn-full");
                                $("#send_time_week").addClass("btn-null");
                            } else {
                                $("#send_time_week").removeClass("btn-null");
                                $("#send_time_week").addClass("btn-full");

                                $("#send_time_month").removeClass("btn-full");
                                $("#send_time_month").addClass("btn-null");
                            }
                            //设置配送时间
                            shop.setSendTime();
                        }
                    }
                });
            },
            setSendTime: function () {

                if ('2' == shop.send_time_type) {

                    for (var i = 1; i <= count; i++) {
                        var obj = {
                            month_day: 10 > i ? '0' + i : i,
                            areaInfo: null == shop.send_time[i] ? null : shop.send_time[i].area.toString()
                        };
                        shop.monthArea.push(obj);
                    }
                    $("#weekArea").css("display", "none");
                    $("#monthArea").css("display", "block");

                } else {

                    for (var i = 0; i < 7; i++) {
                        var obj = {
                            week: week[i],
                            week_day: 10 > weekDays[i] ? '0' + weekDays[i] : weekDays[i],
                            areaInfo: null == shop.send_time[i + 1] ? null : shop.send_time[i + 1].area.toString()
                        };
                        shop.weekArea.push(obj);
                    }
                    $("#weekArea").css("display", "block");
                    $("#monthArea").css("display", "none");
                }
                //这里成功后监测是否显示提示信息
                isShowInputTips();
            },
            editArea: function (i) {
                openAreaModel(i);
            },
            delAddress: function (address) {
                layer.confirm('确定要删除该数据吗？<br> are you sure you want to delete this data ?', {
                    btn: ['<span class="layer_btn_save">确定(determine)</span>', '取消(cancel)'],
                    move:false
                }, function () {

                    $.ajax({
                        url: "{:url('apishop/apishop/delAddr')}",
                        type: 'post',
                        data: {
                            name: address,
                            supplier_id: shop.supplier_id,
                            tag: 1,
                            day: shop.day,
                            sign: 1
                        },
                        success: function (ret) {
                            if (206 == ret.status) {

                                for (var i = 0; i < shop.address[0].area.length; i++) {
                                    if (address == shop.address[0].area[i]) {
                                        shop.address[0].area.splice(i, 1);
                                        break;
                                    }
                                }

                                if ('2' == shop.send_time_type) {
                                    shop.monthArea[shop.day - 1].areaInfo = shop.monthArea[shop.day - 1].areaInfo.replace(',' + address, "");
                                    shop.monthArea[shop.day - 1].areaInfo = shop.monthArea[shop.day - 1].areaInfo.replace(address + ',', "");

                                } else {
                                    shop.weekArea[shop.day - 1].areaInfo = shop.weekArea[shop.day - 1].areaInfo.replace(',' + address, "");
                                    shop.weekArea[shop.day - 1].areaInfo = shop.weekArea[shop.day - 1].areaInfo.replace(address + ',', "");
                                }
                            }
                            layer.msg(ret.msg,{
                                skin:'winning-class',//自定义样式winning-class
                                time:3000
                            });
                        }
                    });
                });
            },
            search_address: function () {
                if ('' == shop.post_code) {
                    return layer.msg('请输入邮政编码<br>please enter post code',{
                        skin:'winning-class',//自定义样式winning-class
                        time:3000
                    });
                }
                $.ajax({
                    url: "{:url('apishop/index/getAreaListByCode')}",
                    type: 'post',
                    data: {
                        code: shop.post_code
                    },
                    success: function (ret) {
                        if (200 == ret.status) {
                            shop.area_list = ret.list;
                        } else {
                            layer.msg(ret.msg,{
                                skin:'winning-class',//自定义样式winning-class
                                time:3000
                            });
                        }
                    }
                });
            },
            set_address: function (i) {
                // var send_area = shop.area_list[i].place_name+','+shop.area_list[i].admin_name3+','+shop.area_list[i].admin_name2+','+shop.area_list[i].admin_name1;

                var send_area;
                if(shop.area_list[i].admin_name2 == ''){
                    send_area = shop.area_list[i].admin_name3;
                }else if(shop.area_list[i].admin_name3 == ''){
                    send_area = shop.area_list[i].place_name;
                }else if(shop.area_list[i].place_name == ''){
                    send_area = shop.area_list[i].admin_name1;
                }else{
                    send_area = shop.area_list[i].admin_name2;
                }
                    $.ajax({
                    url: "{:url('apishop/index/addSendAddress')}",
                    type: 'post',
                    data: {
                        supplier_id: shop.supplier_id,
                        day: shop.day,
                        send_area: send_area
                    },
                    success: function (ret) {
                        if (200 == ret.status) {
                            //添加地址
                            if (shop.address[0] == null) {
                                var data = {area: []};
                                data.area.push(send_area);
                                shop.address.push(data);

                                if ('2' == shop.send_time_type) {
                                    shop.monthArea[shop.day - 1].areaInfo = send_area;
                                } else {
                                    shop.weekArea[shop.day - 1].areaInfo = send_area;
                                }
                            } else {
                                shop.address[0].area.push(send_area);
                                if ('2' == shop.send_time_type) {
                                    shop.monthArea[shop.day - 1].areaInfo += "," + send_area;
                                } else {
                                    shop.weekArea[shop.day - 1].areaInfo += "," + send_area;
                                }

                            }
                            //添加配送时间
                            if (shop.send_time[shop.day] == null) {
                                shop.send_time[shop.day] = {};
                            }
                            Vue.set(shop.send_time, shop.day, shop.address[0]);
                            //shop.setSendTime();

                        } else {
                            layer.msg(ret.msg,{
                                skin:'winning-class',//自定义样式winning-class
                                time:3000
                            });
                        }
                    }
                });
            },
            addDeleteAreaID: function (id) {

                shop.deleteAreaId = id;
            },
            deleteArea: function () {
                if ('' == shop.supplier_id) {
                    return layer.msg('未登录',{
                        skin:'winning-class',//自定义样式winning-class
                        time:3000
                    });
                }
                if ('' == shop.deleteAreaId) {
                    return layer.msg('未选择删除日期',{
                        skin:'winning-class',//自定义样式winning-class
                        time:3000
                    });
                }
                $.ajax({
                    url: "{:url('apishop/index/delAllAddressBySupplierIdDay')}",
                    type: 'post',
                    data: {
                        supplier_id: shop.supplier_id,
                        day: shop.deleteAreaId
                    },
                    success: function (ret) {
                        layer.msg(ret.msg,{
                            skin:'winning-class',//自定义样式winning-class
                            time:3000
                        });
                        if (200 == ret.status) {
                            shop.deleteAreaId = 0;
                            setTimeout(function () {
                                window.location.reload();
                            }, 1000);
                        }
                    }
                });

            },
            editArea: function (i) {
                shop.post_code = '';
                shop.area_list = [];
                openAreaModel(i);
            }
        },
        mounted: function () {

//            this.setSendTime();
        }

    });

    $(document).ready(function () {
        shop.supplier_id = {$id};
        shop.init();
        //弹出框 初始化
        $(".logout_no").on("click", function () {
            $(".modal_tip").css("display", "none");
        });
        $(".modal_zz").on("click", function () {
            $(".modal_tip").css("display", "none");
        })

        $('#myTab a').click(function (e) {
            e.preventDefault()
            $(this).tab('show');
            var title = $(this).html();
            if (title.indexOf("基本信息") >= 0) {
                var title = [];
                title[0] = {navTitle: "首页", e_navTitle: "home page", titleImg: 1};
                title[1] = {navTitle: "店铺管理", e_navTitle: "store management", titleImg: 1};
                title[2] = {navTitle: "基本信息", e_navTitle: "baisc information", titleImg: 0};
                window.parent.editTitle(title);
            } else if (title.indexOf("配送地区") >= 0) {
                var title = [];
                title[0] = {navTitle: "首页", e_navTitle: "home page", titleImg: 1};
                title[1] = {navTitle: "店铺管理", e_navTitle: "store management", titleImg: 1};
                title[2] = {navTitle: "配送地区", e_navTitle: "distribution area", titleImg: 0};
                window.parent.editTitle(title);
            }
        })
        //初始化tree列表
        $.fn.zTree.init($("#treeDemo"), setting);
    });

    function updateSendTimeType() {
        $.ajax({
            url: "{:url('supplies/Shopweb/updateSendTimeType')}",
            type: 'post',
            data: {
                supplier_id: shop.supplier_id,
                type: shop.send_time_type,
            },
            success: function (ret) {
                if (200 == ret.status) {
                    shop.send_time = [];
                    //配置月
                    if ('2' == shop.send_time_type) {
                        $("#send_time_month").removeClass("btn-null");
                        $("#send_time_month").addClass("btn-full");
                        $("#send_time_week").removeClass("btn-full");
                        $("#send_time_week").addClass("btn-null");
                        shop.monthArea = [];

                    } else {
                        $("#send_time_week").removeClass("btn-null");
                        $("#send_time_week").addClass("btn-full");

                        $("#send_time_month").removeClass("btn-full");
                        $("#send_time_month").addClass("btn-null");
                        shop.weekArea = [];
                    }
                    shop.setSendTime();
                    shop.address = [];
                    shop.day = '';
                    layer.closeAll();
                }
            }
        });
    }

    //打开地址框
    function openAreaModel(i) {
        shop.address = [];

        if (shop.send_time[i] != null) {
            shop.address.push(shop.send_time[i]);
        }
        shop.day = i;
    }


    //打开地址框
    function openAddressModel() {
        shop.address = [];
        $('.collection_confirm_box').fadeIn(300);
    }

    //关闭地址框
    function closeAddressModel() {
        $('.collection_confirm_box').fadeOut(300);
        shop.address = [];
        shop.day = '';
    }

    /*获取一个月的天数 */
    function getCurrentMouthDays() {
        var curDate = new Date();
        /!* 获取当前月份 *!/
        var curMonth = curDate.getMonth();
        /!*  生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 *!/
        curDate.setMonth(curMonth + 1);
        /!* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 *!/
        curDate.setDate(0);
        /!* 返回当月的天数 *!/
        return curDate.getDate();
    }

    //获得本周7天的日期
    function getCurrentWeekDays() {
        var now = new Date(); //当前日期
        var nowDayOfWeek = now.getDay(); //今天本周的第几天
        var nowDay = now.getDate(); //当前日
        var nowMonth = now.getMonth(); //当前月
        var nowYear = now.getYear(); //当前年
        var weekDays = [];
        for (var i = 1; i < 8; i++) {
            var weekEndDate = new Date(nowYear, nowMonth, nowDay + (i - nowDayOfWeek)).getDate();
            weekDays[i - 1] = weekEndDate;
        }
        return weekDays;
    }

    var suppliesId = localStorage.getItem("suppliesId");
    //树形tree列表
    var setting = {
        view: {
            selectedMulti: false
        },
        check: {
            enable: true,
            chkboxType: {"Y": "p", "N": "s"}
        },
        async: {
            enable: true,
            url: "/apishop/apishop/getDatabase",
            autoParam: ["name"],
            otherParam: {"supplier_id": suppliesId},
            dataFilter: filter
        },
        callback: {
            beforeClick: beforeClick,
            beforeAsync: beforeAsync,
            onAsyncError: onAsyncError,
            onAsyncSuccess: onAsyncSuccess
        }
    };

    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i = 0, l = childNodes.length; i < l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    }

    function beforeClick(treeId, treeNode) {
        if (!treeNode.isParent) {
            {
                // alert(111);
                // $("#txt_area").val(treeNode.name);
                // $("#div_tree").hide();
                // return false;
            }
        } else {
            return true;
        }
    }

    var log, className = "dark";

    function beforeAsync(treeId, treeNode) {

        className = (className === "dark" ? "" : "dark");
        showLog("[ " + getTime() + " beforeAsync ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
        return true;
    }

    function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
        showLog("[ " + getTime() + " onAsyncError ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
    }

    function onAsyncSuccess(event, treeId, treeNode, msg) {
        showLog("[ " + getTime() + " onAsyncSuccess ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
    }

    function showLog(str) {
        if (!log) log = $("#log");
        log.append("<li class='" + className + "'>" + str + "</li>");
        if (log.children("li").length > 8) {
            log.get(0).removeChild(log.children("li")[0]);
        }
    }

    function getTime() {
        var now = new Date(),
            h = now.getHours(),
            m = now.getMinutes(),
            s = now.getSeconds(),
            ms = now.getMilliseconds();
        return (h + ":" + m + ":" + s + " " + ms);
    }

</script>

</html>